package com.adteam.xmap.web;

import java.util.List;

import com.adteam.xmap.entity.Transaction;
import com.adteam.xmap.manager.TransactionManager;
import com.opensymphony.xwork2.ActionSupport;

public class TransactionAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	
	private TransactionManager transactManager;
	
	private Transaction transaction;
	
	private List transactions;
	
	private Integer id;

	@Override
	public String execute() throws Exception {
		
		transactions = transactManager.findAllTransactions();
		return "SUCCESS";
	}
	
	public String addInput() {
		
		return "add_input";
	}
	
	public String add() {
		
		transactManager.addTransaction(transaction);
		return "add_success";
	}
	
	public String del() {
		
		transactManager.delTransaction(id);
		return "del_success";
	}
	
	public String updateInput() {
		
		return "update_input";
	}
	
	public String update() {
		
		transactManager.updateTransaction(transaction);
		return "update_success";
	}
	
	public String find() {
		
		transaction = transactManager.findTransactionById(id);
		return "find_success";
	}

	public void setTransactManager(TransactionManager transactManager) {
		this.transactManager = transactManager;
	}

	public Transaction getTransaction() {
		return transaction;
	}

	public void setTransaction(Transaction transaction) {
		this.transaction = transaction;
	}

	public List getTransactions() {
		return transactions;
	}

	public void setTransactions(List transactions) {
		this.transactions = transactions;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public TransactionManager getTransactManager() {
		return transactManager;
	}



}
